<extend name="Public/user"/>
<block name="link">
	<title>我要下单</title>
	<link href="/static/lida/css/tran_style.css" rel="stylesheet" type="text/css" />
	<link href="__CSS__/bootstrap.min.css" rel="stylesheet"/>
	<script src="__JS__/jquery.js"></script>
	<script src="__JS__/bootstrap.js"></script>
	<script type="text/javascript" src="__STATIC__/thinkbox/thinkbox/jquery.thinkbox.js"></script>
	<link href="__CSS__/ksfh-style.css" rel="stylesheet"/>
	<link rel="stylesheet" type="text/css" href="__CSS__/common.css">
</block>
<block name="user-right">
	<!--main_right-->
	<div class="main_r f_fr">
		<div class="user_kx">
			<h3 class="user_kx_title">
				{:lang('order_info')}
			</h3>
			<table class="table table-striped table-bordered" id='yubao-adds' style="border:none;">
				<tbody>
				<tr>
					<td width="80">{:lang('order_num')}：</td>
					<td>{$ddinfo.sn}</td>
					<td>{:lang('add_time')}：</td>
					<td>{$ddinfo.addtime|time_format}</td>
				</tr>
				<tr>
					<td>{:lang('delivery_info')}：</td>
					<td colspan="3">{$ddinfo.consignee}({$ddinfo.tel}) &nbsp; {$ddinfo.areaname} {$ddinfo.address}({$ddinfo.zipcode})</td>
				</tr>
				<tr>
					<td>{:lang('freight_info')}：</td>
					<td colspan="3">{$ddinfo.freight_info}</td>
				</tr>
				<tr>
					<td>{:lang('remark')}：</td>
					<td colspan="3">{$ddinfo.remark}</td>
				</tr>
				<tr>
					<td>费用总计：</td>
					<td colspan="3"><span  style="font-size: 16px;font-weight: bold;display: inline-block;padding: 0 5px;color: red;">{$ddinfo.freight}{:config('MAIN_COIN')}</span></td>
				</tr>
				</tbody>
			</table>

		</div>
		<div class="user_kx">
			<h5 class="user_kx_title">
				在线支付支付
			</h5>
			<table class="table table-striped table-bordered" id='yubao-adds' style="border:none;">
				<tbody>
					<tr >
						<td><label>
							    <input type="radio" name="pay_method" value="predeposit" <php>if($member['available_predeposit']<$ddinfo['freight']){echo 'disabled';}else{echo 'checked';};</php> >
							    使用预存款支付 （可用余额：{$member.available_predeposit}日元）
							  </label>
在线充值可获取积分&nbsp;<a href="/store/member/index.php?act=predeposit&op=recharge_add" target="_blank" class=" btn btn-info" >立即充值</a></td>
					</tr>
				<tr>
					<td><label> <input type="radio" name="pay_method" value="wechat"> 微信
					</label></td>
				</tr>
				<tr>
					<td><label> <input type="radio" name="pay_method" value="alipay"> 支付宝
					</label></td>
				</tr>
			</tbody>
			</table>
		
		</div>
		<div class="user_kx">
			<h3 class="user_kx_title">
				打包列表
			</h3>
			<table class="table table-striped table-bordered" id='yubao-adds' style="border:none;">
				<tbody>
				<tr>
					<th width="50" style="display: none">{:lang('check')}</th>
					<th>{:lang('guoji_delivery_num')}</th>
					<th>转国内运单号</th>
					<th width="80">{:lang('weight')}</th>
					<th width="80">{:lang('index_volume')}</th>
					<th>{:lang('remark')}</th>
					<th width="80">{:lang('freight')}{:config('MAIN_COIN')}</th>
				</tr>
				<volist name="bglist" id="v">
					<tr >
						<td align="center"  style="display: none">
							<eq name="v.haspay" value="1">{:lang('has_pay')}
								<else/>
								<eq name="v.status" value="9">{:lang('withholding')}
									<else />
									<input type="checkbox" name="bgid[]" value="{$v.id}" checked>
								</eq>
							</eq>
						</td>
						<td>{$v['bgsn']? $v['bgsn']:''}</td>
							<td>{$v['in_express']? $v['in_express']:'暂无'}</td>
						<td>{$v['weight']? $v['weight']:''}</td>
						<td>{$v['voweight']? $v['voweight']:''}</td>
						<td>{$v['remark']? $v['remark']:''}</td>
						<td align="right"><b style="color:red;" class="freight">{$v.freight}</b></td>
					</tr>
				</volist>
				</tbody>
			</table>

		</div>
		<div class="user_kx">
			<div style="border: 1px solid #dfdfdf;height:100px;padding: 10px;font-size: 14px;text-align: right;line-height: 25px;">
				{:lang('need_to_pay')}
				<span id="allfreight" style="font-size: 20px;font-weight: bold;display: inline-block;padding: 0 5px;color: red;"></span>
				{:config('MAIN_COIN')}
				<br>
				{:lang('your_balance')}：{$member.available_predeposit} ({:config('MAIN_COIN')}) &nbsp;  {:config('MAIN_COIN')}
				<div class="blank"></div>
				<div style="width:200px;float: right;line-height: 20px;">
					<a href="{:url('User/chongzhi')}" target="_blank" class=" btn btn-danger" id="quchongzhi">{:lang('recharge')}</a>
					<a href="javascript:;"   class=" btn btn-danger" style="background:#2CDE98;border: 1px solid #2CDE98;" id="querenzhifu">{:lang('confirm_pay')}</a>
				</div>
				<div class="clear"></div>
			</div>

		</div>

	</div>
</block>
<block name="javascript">
	<script type="text/javascript">
		$(function(){
			var allfreight=0;
			var svfreight=0;
			$('input[name="bgid[]"]:checked').each(function(){
				frei=$(this).parents('tr').find('.freight').html();
				//svfreight+=Math.round(parseFloat(frei)*0.023);
				//alert(svfreight);
				allfreight+=parseFloat(frei);
			})
			$('#svfreight').html(svfreight);
			$('#allfreight').html(allfreight+svfreight);

			if (allfreight.toFixed(2)<=<?php echo $member['available_predeposit']+$member['credit'] ?>) {
			$('#querenzhifu').show();
			$('#quchongzhi').hide();
		}else{
			$('#querenzhifu').hide();
			$('#quchongzhi').show();
		};
		if (allfreight.toFixed(2)<=0.00) {
			$('#querenzhifu').hide();
			$('#quchongzhi').hide();
		};
		$('input[name="bgid[]"]').click(function(){
				if ($(this).prop('checked')) {
				frei=$(this).parents('tr').find('.freight').html();
				yunfei=parseFloat(frei)+parseFloat($('#allfreight').html());
				$('#allfreight').html(yunfei.toFixed(2));
				if (yunfei.toFixed(2)<=<?php echo $member['available_predeposit']+$member['credit'] ?>) {

				if (yunfei.toFixed(2)<=0.00) {
				$('#querenzhifu').hide();
				$('#quchongzhi').hide();
			}else{
				$('#querenzhifu').show();
				$('#quchongzhi').hide();
			};

			}else{
				$('#querenzhifu').hide();
				$('#quchongzhi').show();
			};
			}else{
				frei=$(this).parents('tr').find('.freight').html();
				yunfei=parseFloat($('#allfreight').html())-parseFloat(frei);
				$('#allfreight').html(yunfei.toFixed(2));
				if (yunfei.toFixed(2)<=<?php echo $member['available_predeposit']+$member['credit'] ?>) {
				if (yunfei.toFixed(2)<=0.00) {
				$('#querenzhifu').hide();
				$('#quchongzhi').hide();
			}else{
				$('#querenzhifu').show();
				$('#quchongzhi').hide();
			};
			}else{
				$('#querenzhifu').hide();
				$('#quchongzhi').show();
			};
			};
			})
			$('#querenzhifu').click(function(){
		var ddid=<?php echo $ddinfo['id'] ?>;
		var bgid="";
		$('input[name="bgid[]"]:checked').each(function(){
			bgid+=$(this).val()+',';
			})
			$.post("{:url('User/paydingdan')}",{'ddid':ddid,'bgid':bgid},function(data){
			if (data.status) {
				$.thinkbox.success(data.info);
				setTimeout(jumpurl(data.url),3000);
			}else{
				$.thinkbox.error(data.info);
			};
		})
	})
	})

		function jumpurl(uri){
			window.location.href=uri;
		}
	</script>
</block>